let str1 = `activeClass`;
let str2 = `{active:isActive,'text-danger':hasError}`;
let str3 = `[activeClass,errorClass]`;

function evaluate(expression, vm) {
    return getEvaluate(expression, vm).call(vm);
}
function getEvaluate(expression, vm) {
    return new Function(`with(this){return ` + expression + `}`).bind(vm);
}
var vm = {
    activeClass:'active',
    errorClass:'error',
    isActive:true,
    hasError:true
}
console.log(evaluate(str1,vm))
console.log(evaluate(str2,vm))
console.log(evaluate(str3,vm))